"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.deepClone = void 0;

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

/**
 * 深拷贝
 * @param obj 要拷贝的对象
 * @param options 可以配置ignore数组设置忽略的项目
 * ```js
 *   const a = { a: { b: 1 } };
 *   const c = deepClone(a);
 * ```
 */
var deepClone = function deepClone(obj, options) {
  var o = obj.constructor === Array ? [] : {};

  for (var i in obj) {
    if (options !== null && options !== void 0 && options.ignore && options.ignore.indexOf(i) >= 0) {
      continue;
    } // eslint-disable-next-line no-prototype-builtins


    if (obj.hasOwnProperty(i)) {
      o[i] = obj[i] && _typeof(obj[i]) === 'object' ? deepClone(obj[i]) : obj[i];
    }
  }

  return o;
};

exports.deepClone = deepClone;